package com.lois.controller;

import com.lois.model.UploadData;
import com.lois.service.UploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author lois
 * @since 2020-03-02
 */
@Slf4j
@RestController
@RequestMapping("/base")
public class UploadController {

    @Autowired
    private UploadService uploadService;


    /**
     * 文件上传
     */
    @PostMapping("/upload")
    public String upload(MultipartFile file) throws IOException {
        uploadService.upload(file.getInputStream());
        return "success";
    }

    /**
     * 文件上传
     */
    @GetMapping("/findList")
    public List<UploadData> findList() throws IOException {
         return uploadService.findList();
    }

}
